package com.zm.api.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zm.api.dao.UserInfoDao;
import com.zm.api.model.UserInfo;
import com.zm.api.service.UserInfoService;
import org.springframework.stereotype.Service;

@Service
public class UserInfoServiceImpl extends ServiceImpl<UserInfoDao, UserInfo> implements UserInfoService {
    @Override
    public boolean pay(Long userId, Long price) {
        boolean result=false;
        UserInfo byId = this.getById(userId);
        if (byId!=null&&price<=byId.getMoney()){
            byId.setMoney(byId.getMoney()-price);
            result = byId.updateById();
        }
        return result;
    }
}
